-
Notifications
You must be signed in to change notification settings - Fork 368
Introduce metric representing N+ license expiration date #1102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Hi @defanator! Welcome to the project! 🎉 Thanks for opening this pull request! |
@mpstefan @pdabelf5 @javorszky appreciate extra eyes on this one gentlemen, it would be great if it could land into next release of exporter itself + hopefully included into one of the next NIC releases. We have a few ongoing and upcoming tasks where we do consider lack of proposed metric as a blocker. TIA! |
@@ -283,6 +283,7 @@ func NewNginxPlusCollector(nginxClient *plusclient.NginxClient, namespace string | |||
"ssl_handshakes": newGlobalMetric(namespace, "ssl_handshakes", "Successful SSL handshakes", constLabels), | |||
"ssl_handshakes_failed": newGlobalMetric(namespace, "ssl_handshakes_failed", "Failed SSL handshakes", constLabels), | |||
"ssl_session_reuses": newGlobalMetric(namespace, "ssl_session_reuses", "Session reuses during SSL handshake", constLabels), | |||
"license_active_till": newGlobalMetric(namespace, "license_expiration_timestamp_seconds", "License expiration date (expressed as Unix Epoch Time)", constLabels), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would the license grace period be useful here too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
likely, but what would be the reliable way to extract this one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the grace period is available in the embedded reporting struct.
license, err := c.nginxClient.GetNginxLicense(context.TODO())
if err != nil {
c.logger.Warn("error getting license information", "error", err.Error())
} else {
ch <- prometheus.MustNewConstMetric(c.totalMetrics["license_active_till"],
prometheus.GaugeValue, float64(license.ActiveTill))
ch <- prometheus.MustNewConstMetric(c.totalMetrics["license_grace_period"],
prometheus.GaugeValue, float64(license.Reporting.Grace))
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting - I'll take a closer look. I didn't see anything but these from N+:
defan@lb1:~$ curl -fs http://localhost:8888/api/9/license | jq
{
"active_till": 1767744000,
"eval": false
}
(If that grace period is something that is being populated by nginx-plus-go-client based on any assumptions - i.e. not coming directly from N+ - I'd rather not include this as a separate metric.)
UPD: the above output was obtained from nginx-plus-r33-p2.
Proposed changes
This PR adds N+ specific metric indicating license expiration date. Primary purpose of this one is to be used in associated alerting, as N+ API is the lowest possible source of truth in regard to license validity period.
The semantic is borrowed from similar cert-manager metrics which are widely used in lots of environments.
Example output in Prometheus format:
Checklist
Before creating a PR, run through this checklist and mark each as complete.